<template>
    <div>
        
        <!-- 顶部导航 -->
        <van-nav-bar title="个人中心" left-text="返回" right-text="退出" left-arrow @click-left="$router.go(-1)"
            @click-right="onClickRight" />
        <!-- cell单元格组件 -->
        个人中心
        <van-cell title="地址管理" is-link to="/address" />
        <van-cell title="订单中心" is-link to="/order" />
    </div>
</template>

<script setup lang="ts">
import { Dialog } from 'vant';
import { ref, reactive, computed, watch, defineProps, defineEmits } from 'vue'
import { useUserStore } from '@/store/useUserStore'
import { useregisterStore} from '@/store/useregisterStore'
import {useRouter} from 'vue-router'
const UserStore = useUserStore()
const registerStore= useregisterStore()
const router = useRouter()
let onClickRight = () => {
    Dialog.confirm({
        message:
            '确认要退出登录吗?',
    })
        .then(() => {
            // on confirm点击确定退出登录，清空pinia中的数据，清空本地token,跳转到首页
            UserStore.setUseId('')
            UserStore.setToken('')
            localStorage.setItem('token','')
            registerStore.setTel('')
            registerStore.setPwd('')
            router.push('/home')
        })
        .catch(() => {
            // on cancel
        });
}
</script>
<style scoped>

</style>